<?php
// +---------------------------------------------------------------------------+
// | This file is part of the KnowledgebasePublisher package                   |
// | KnowledgebasePublisher - web based knowledgebase publisher tool           |
// |                                                                           |
// | Author:  Evgeny Leontev <eleontev@gmail.com>                              |
// | Copyright (c) 2005 Evgeny Leontev                                         |
// |                                                                           |
// | For the full copyright and license information, please view the LICENSE   |
// | file that was distributed with this source code.                          |
// +---------------------------------------------------------------------------+

class DAOIterator
{
	
	function DAOIterator(&$result) {
		$this->result = &$result
	}
	
	 
	function &FetchRow() {
		return $this->result->FetchRow();
	}
	
	
}


$it = &new $manager->getRecords();
foreach($array as $k => $v) {
	
}


class KBCommonModel extends AppModel
{
	var $tbl_pref_custom = 'kb_';

}


class KBCommentModel extends KBCommonModel
{
	
	
	var $tables = array('table'=>'comment', 'comment', 'entry');
	
	
	
	function getById($record_id) {
		$sql = "SELECT c.*, e.title, UNIX_TIMESTAMP(c.date_posted) AS ts
		FROM {$this->tbl->comment} c, {$this->tbl->entry} e
		WHERE e.id = c.entry_id
		AND c.id = ?";
		$result =& $this->db->Execute($sql, $record_id) or die(db_error($sql));
		return $result->FetchRow();
	}
	
	
/*
	function getByEntryId($record_id) {
		$sql = "SELECT c.*, e.question, UNIX_TIMESTAMP(c.date_posted) AS ts
		FROM {$this->tbl->comment} c, {$this->tbl->entry} e
		WHERE e.id = c.entry_id
		AND c.entry_id = ?";
		$result =& $this->db->Execute($sql, $record_id) or die(db_error($sql));
		return $result->FetchRow();
	}
*/
	

	function getRecordsSql() {
	
		//$date = $this->db->SQLDate('M d, Y','c.date_posted');
		//, {$date} AS formated_date
		
		//$ts = $this->db->DBTimeStamp('c.date_posted');
		//, {$date} AS formated_date
		//UNIXTIMESTAMP(c.date_posted)
		
		$sql = "SELECT c.*, e.title, UNIX_TIMESTAMP(c.date_posted) AS ts,
		CONCAT(SUBSTRING_INDEX(c.comment,' ',20), '...') AS comment
		FROM {$this->tbl->comment} c, {$this->tbl->entry} e
		WHERE e.id = c.entry_id  
		AND {$this->sql_params}
		{$this->sql_params_order}";
		
		//echo "<pre>"; print_r($sql); echo "</pre>";
		return $sql;
	}		
	
	
	
	// ACTIONS // ---------------------
	
	
	
	
	// DELETE RELATED // ---------------------
		
}
?>
